<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller {

    public function _initialize(){
        //php判断客户端是否为手机
        $agent = $_SERVER['HTTP_USER_AGENT'];
        if(strpos($agent,"NetFront") || strpos($agent,"iPhone") || strpos($agent,"MIDP-2.0") || strpos($agent,"Opera Mini") || strpos($agent,"UCWEB") || strpos($agent,"Android") || strpos($agent,"Windows CE") || strpos($agent,"SymbianOS"))
        {
            header("Location:http://www.midilevel.com/index.php/Web");
            exit();
        }
        //如果session存在，传递用户信息
        $midiuser = session('midiuser');
        $this->assign('midiuser',$midiuser);
    }

    /**
    * 发送短信验证码
    * @param user_phone      要发送的手机号码
    */
    public function sendMsgCode(){

        // $_POST['user_phone'] = '13811341066';

        $phonenums = $_POST['user_phone'];
        $code = createRandomCode(4);
        alidayucode($code, $phonenums); //发送短信
        $this->backToClient(1,'获取短信验证码成功',$code);
    }

}